import { localRead, localSave } from "@/lib/local"
export default {
  state: {
    token: localRead("token"),
    userInfo: localRead("userInfo"),
  },
  getters: {
    getToken: (state) => state.token,
    getUserInfo: (state) => state.userInfo,
  },
  mutations: {
    setToken: (state, token) => {
      state.token = token
      localSave("token", token)
    },
    getUserInfo: (state, userInfo) => {
      state.userInfo = userInfo
      localSave("userInfo", userInfo)
    },
  },
  actions: {
    getToken: ({ commit }, token) => {
      commit("setToken", token)
    },
    getUserInfo: ({ commit }, userInfo) => {
      commit("serUserInfo", userInfo)
    },
  },
}
